﻿@{
    Bundle("jquery_validate");
}

<script type="text/javascript">
    jQuery(document).ready(function () {
        jQuery('@ID("#form")').validate({
            rules: {
                amount: {
                    required: true
                },
                handlingFee: {
                    required: true
                }
            }
        });
        jQuery.ajax({
            type: 'post',
            url: '@Url.Action(Loc.Act("Processors").Ctrl("Payment"))',
            dataType: 'json',
            success: function (rsp) {
                var ddl = jQuery('@ID("#ddl_processor")');
                ddl.empty();
                jQuery.each(rsp, function (k, v) {
                    ddl.append('<option value=' + v.id + '>' + v.value + '</option>');
                });
                ddl.val('@JDM.Guid(Model.ProcessorID)');
                ddl.change();
            }
        });
    });
</script>
<form id="@ID("form")" action="@Url.Action(Loc.Act("Update").Ctrl("Payment"))" method="post">
    <input type="hidden" name="flags" value="@JDM.String(Model.Flags)" />
    <table>
        <tr>
            <td>
                <label>#</label>
            </td>
            <td>
                <input type="text" readonly name="id" value="@JDM.Int32(Model.EntityID)" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.In("Common").Of("Vocab").Name("Guid"))</label>
            </td>
            <td>
                <input type="text" readonly value="@JDM.Guid(Model.Guid)" />
            </td>
        </tr>
        <tr>
            <td>
                <label>&#10001;</label>
            </td>
            <td>
                <input type="text" readonly value="@Svc.DateTime((DateTime)JDM.DateTime(Model.CreatedOn))" />
            </td>
        </tr>
        <tr>
            <td>
                <label>&#10002;</label>
            </td>
            <td>
                <input type="text" readonly value="@Svc.DateTime((DateTime)JDM.DateTime(Model.UpdatedOn))" />
            </td>
        </tr>
        <tr>
            <td>
                <a href="@Url.Action(Loc.Act("Edit").Ctrl("Customer").Set(new
                {
                    id = JDM.Int32(Model.Customer.EntityID)
                }))" class="ui-icon ui-icon-extlink"></a>
                <label>@T(Res.Name("Customer"))</label>
            </td>
            <td>
                <input type="text" readonly value="@JDM.String(Model.Customer.Account.Email)" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("Processor"))</label>
            </td>
            <td>
                <select id="@ID("ddl_processor")" disabled></select>
            </td>
        </tr>
        <tr>
            <td>
                <a href="@Url.Action(Loc.Act("Edit").Ctrl("Invoice").Set(new
                {
                    id = JDM.Int32(Model.Invoice.EntityID)
                }))" class="ui-icon ui-icon-extlink"></a>
                <label>@T(Res.Name("Invoice"))</label>
            </td>
            <td>
                <input type="text" readonly value="@JDM.Int32(Model.Invoice.EntityID)" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("Amount"), JDM.String(Svc.Localization.Currency.Code))</label>
            </td>
            <td>
                <input type="text" name="amount" value="@Svc.Price((decimal)JDM.Decimal(Model.Amount))" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("HandlingFee"), JDM.String(Svc.Localization.Currency.Code))</label>
            </td>
            <td>
                <input type="text" name="handlingFee" value="@Svc.Price((decimal)JDM.Decimal(Model.HandlingFee))" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("Status"))</label>
            </td>
            <td>
                <ul class="bar">
                    <li>
                        <input type="radio" disabled @(JDM.HasFlags(Model.Flags, "Voided") ? "checked" : String.Empty) />
                    </li>
                    <li>
                        <label>@T(Res.In("API").Of("Enum").Of("PaymentFlags").Name("Voided"))</label>
                    </li>
                    <li>
                        <input type="radio" disabled @(JDM.HasFlags(Model.Flags, "Refunded") ? "checked" : String.Empty) />
                    </li>
                    <li>
                        <label>@T(Res.In("API").Of("Enum").Of("PaymentFlags").Name("Refunded"))</label>
                    </li>
                    <li>
                        <input type="radio" disabled @(JDM.HasFlags(Model.Flags, "Pending") ? "checked" : String.Empty) />
                    </li>
                    <li>
                        <label>@T(Res.In("API").Of("Enum").Of("PaymentFlags").Name("Pending"))</label>
                    </li>
                    <li>
                        <input type="radio" disabled @(JDM.HasFlags(Model.Flags, "Authorized") ? "checked" : String.Empty) />
                    </li>
                    <li>
                        <label>@T(Res.In("API").Of("Enum").Of("PaymentFlags").Name("Authorized"))</label>
                    </li>
                    <li>
                        <input type="radio" disabled @(JDM.HasFlags(Model.Flags, "Captured") ? "checked" : String.Empty) />
                    </li>
                    <li>
                        <label>@T(Res.In("API").Of("Enum").Of("PaymentFlags").Name("Captured"))</label>
                    </li>
                </ul>
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.In("API").Of("Enum").Of("PaymentFlags").Name("Active"))</label>
            </td>
            <td>
                <input type="checkbox" disabled @(JDM.HasFlags(Model.Flags, "Active") ? "checked" : String.Empty) />
            </td>
        </tr>
    </table>
    <ul class="bar toolbar">
        <li><button class="button" type="submit">@T(Res.In("Common").Of("Act").Name("Submit"))</button></li>
    </ul>
</form>